package com.itheima.tanhuan.vo.db;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.itheima.tanhuan.pojo.db.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ContactVo implements Serializable {
    private Integer id;//主键id
    private String userId;//用户id
    private String avatar;//头像
    private String nickname;//昵称
    private String gender;//性别
    private Integer age;//年龄
    private String city;//城市

    public static ContactVo init(UserInfo userInfo) {
        ContactVo vo = new ContactVo();
        if (userInfo != null) {
            BeanUtils.copyProperties(userInfo, vo);
            vo.setUserId("hx" + userInfo.getId().toString());
        }
        return vo;
    }
}
